package pageobjects;

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import common.PageObjectCommonFunctions;
/**
 * 
 * This page object describe the Feedback page
 *
 */
public class FeedbackPage extends PageObjectCommonFunctions{
	/********************************************* LOCATORS *********************************************/
	private static final String redoCSS = "form[id='redo'] input";										
	/***************************************************************************************************/
	public static final String REDO = "redo";
	
	Map<String, String> pageLocators = new HashMap<String, String>();

	public FeedbackPage(WebDriver driver) {
		
		super(driver);
		pageLocators.put(REDO, redoCSS);
		
	}
	
	public void redoQuiz(){
		
		driver.findElement(By.cssSelector(redoCSS)).click();
		waitUntilFirstQuestionAvailable(QuestionnairePage.PROGRESS_BAR);
		
	}
	
	/**
	 * This is the wrapper for the wait condition 
	 * Avoid stale exceptions.The locator used is stable but suboptimal
	 * Need an expression which contains the actual element we are expecting to click
	 * waitUntilVisible(By.xpath("//div[@id='quiz']/form/div[@class='select-one']/ul/li["+loc+"]/button"));
	 */
	public void waitUntilFirstQuestionAvailable(String locator) {
		
	    waitUntilVisible(By.cssSelector(locator));    
	    
	  }

}
